function [c,ceq] = nlin2c_p2(x)

%load remaining data
data_struct = load('data2c.mat');
Y = data_struct.Y;
segNP = double(data_struct.segNP);
upMat = data_struct.upMat;
os = double(data_struct.os);
uniqSeg = double(data_struct.uniqSeg);
prices = double(data_struct.prices);
segScale = double(data_struct.segScale);
segQ = double(data_struct.segQ);
uniqSeg_size = size(uniqSeg);
nNewSegments = uniqSeg_size(1);
prices_size = size(prices);
nProducts = prices_size(1);
[y1,y2,~]=ind2sub(size(upMat),find(upMat));

prices_lb = zeros(nProducts,nProducts,nNewSegments);
for i=1:nNewSegments
     prices_lb(y1(i),y2(i),i) = prices(y1(i));
end

u = zeros(nNewSegments,3+nProducts);
usub = zeros(nNewSegments,nProducts);
for i = 1:nNewSegments
    u(i,:) = [uniqSeg(i,1)+1,y1(i),y2(i),os(uniqSeg(i,3)+1,:)];
    usub(i,:) = os(uniqSeg(i,3)+1,:);
    usub(i,y2(i)) = 0;
end

ceq = [];
for i = 1:nNewSegments
    c(i) = x(i) - Y(y1(i),y2(i),i)*(exp(1/segScale(u(i,1))*(segQ(u(i,3),u(i,1))-(prices(u(i,2))+x(nNewSegments+1)*(prices(u(i,3))-prices(u(i,2))))))...
        /(exp(1/segScale(u(i,1))*(segQ(u(i,2),u(i,1))-prices(u(i,2))))...
        +exp(1/segScale(u(i,1))*(segQ(u(i,3),u(i,1))-(prices(u(i,2))+x(nNewSegments+1)*(prices(u(i,3))-prices(u(i,2))))))));
end

end